/*
 *  解决原代码接口变量携带服务问题
 */
import axios from 'axios';
const service = axios.create({
  timeout: 1000 * 30,
  headers: {
    'Content-Type': 'application/json;charset=utf-8'
  },
  baseURL: process.env.NODE_ENV === 'development' ? '/apis' : process.env.VUE_APP_BASE_API
});

service.interceptors.request.use(
  config => {
    config.headers.Authorization = 'bearer ' + localStorage.getItem('managementToken');
    return config;
  },
  error => {
    return Promise.reject(error);
  }
);

service.interceptors.response.use(
  res => {
    return res;
  },
  error => {
    return Promise.reject(error);
  }
);

export default service;
